/**
 * @param {string} key
 * @param {string} message
 * @return {string}
 */
var decodeMessage = function(key, message) {
  key = key.split(" ").join("");
  let map = new Map(), index = 0;
  for(let i = 0; i < key.length; i++) {
    if(map.has(key[i])) continue;
    else {
      map.set(key[i], String.fromCharCode('a'.charCodeAt() + index));
      index++;
    }
  }
  let result = "";
  for(let i = 0; i < message.length; i++) {
    if(message[i] == " ") {
      result += " ";
      continue;
    }
    result += map.get(message[i]);
  }
  return result;
};
let key = "the quick brown fox jumps over the lazy dog", message = "vkbs bs t suepuv";
console.log(decodeMessage(key, message));
key = "eljuxhpwnyrdgtqkviszcfmabo", message = "zwx hnfx lqantp mnoeius ycgk vcnjrdb";
console.log(decodeMessage(key, message));
key = "aowrzlqeyicbnbdyvfsmbrgbkethbuueraldpqfwkukmvmphuccxjdrczf", message = "uoeazfvmhiqjnvdverxxglfubcfrnhrsmabdqdaqolvjnilt ";
console.log(decodeMessage(key, message));
